package org.example;

import org.example.JavaBean.Emp;
import org.example.Service.EmpService;
import org.example.util.DateUtil;
import org.example.util.JsonResult;
import org.example.util.ResultTool;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
*@Auther:Liu
*@Testname:${NAME}
*@Date:2025/7/29   11:01
*///TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main {
    @Test
    public  void a(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.example");
        EmpService bean = context.getBean(EmpService.class);
        JsonResult all = bean.findByName("张");
        System.out.println(all);
    }

    @Test
    public  void b(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.example");
        EmpService bean = context.getBean(EmpService.class);
        JsonResult all = bean.findAll();
        System.out.println(all);
    }
    @Test
    public  void c(){
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.example");
        EmpService bean = context.getBean(EmpService.class);
        JsonResult all = bean.findByPage(1,10);
        System.out.println(all);
    }
    @Test
    public  void d() throws ParseException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.example");
        EmpService bean = context.getBean(EmpService.class);
        Emp emp = new Emp();
        emp.setEname("张三11111");
        emp.setJob("工程师");
        emp.setMgr(2000);
        emp.setSal(23.45);
        emp.setComm(null);
        emp.setDeptno(20);
        JsonResult i = bean.Insert(emp);
        System.out.println(i);
    }
@Test
    public  void e() throws ParseException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.example");
        EmpService bean = context.getBean(EmpService.class);
        JsonResult i = bean.Delete(8077);
        System.out.println(i);
    }

    @Test
    public  void f() throws ParseException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.example");
        EmpService bean = context.getBean(EmpService.class);
        Emp emp = new Emp();
        emp.setEname("张三666");
        emp.setJob("开发师");
        emp.setMgr(6000);
        emp.setSal(23.45);
        emp.setComm(null);
        emp.setDeptno(40);
        emp.setEmpno(8078);
        JsonResult update = bean.Update(emp);
        System.out.println(update);
    }

    @Test
    public  void g() throws ParseException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext("org.example");
        EmpService bean = context.getBean(EmpService.class);
        Emp emp = new Emp();
        emp.setEname("张三666");
        emp.setJob("开发师");
        emp.setMgr(6000);
        emp.setSal(23.45);
        emp.setComm(null);
        emp.setDeptno(40);
        emp.setEmpno(8078);
        JsonResult jsonResult = bean.UpdateOrInsert(emp);
        System.out.println(jsonResult);
    }
}